******************************************************
*** TABLE 3: Dynamic Effect of Moderators on IP Rate.
******************************************************


use "$DATALOC/AgencyLevel.dta", clear
* Number of words.  
eststo a3_1: reghdfe iprate agen_hear_all last_agen_hear agen_nwords_all lXagen_nwords_last_hr,  a(agency FY)
	quietly estadd local fixedyear "Yes", replace
	quietly estadd local fixedagency "Yes", replace
	estadd ysumm, replace	
* Number of AGENCY witnesses. 
eststo a3_2: reghdfe iprate agen_hear_all last_agen_hear agen_nwitnessagency_all lXagen_nwitnessagency_last_hr ,  a(agency FY)
	quietly estadd local fixedyear "Yes", replace
	quietly estadd local fixedagency "Yes", replace
	estadd ysumm, replace	

use "$DATALOC/ProgramLevel.dta", clear
* Number of words.  
eststo p3_1: reghdfe iprate agen_hear_all last_agen_hear agen_nwords_all lXagen_nwords_last_hr,  a(programname FY) $CLUSTERCODE
	quietly estadd local fixedyear "Yes", replace
	quietly estadd local fixedagency "Yes", replace
	estadd ysumm, replace	
* Number of AGENCY witnesses. 
eststo p3_2: reghdfe iprate agen_hear_all last_agen_hear agen_nwitnessagency_all lXagen_nwitnessagency_last_hr ,  a(programname FY) $CLUSTERCODE
	quietly estadd local fixedyear "Yes", replace
	quietly estadd local fixedagency "Yes", replace
	estadd ysumm, replace	
	
*** OUTPUT TABLE
esttab a3_1 a3_2 p3_1 p3_2 using "$TABLELOC/Table03.tex", ///
	prehead("\begin{table}[htbp]\centering \def\sym#1{\ifmmode^{#1}\else\(^{#1}\)\fi} \caption{Dynamic Effect of Moderators on Improper Payment Rate. Dependent variable is improper payment rate as a percent of all payments.} \resizebox{\textwidth}{!}{ \begin{tabular}{l*{5}{c}} \toprule") ///
	b(a2) fragment ///
	booktabs label se star(** 0.05 *** 0.01)s(fixedyear fixedagency N, label("Fiscal Year FE" "Agency/Program FE" "Observations")) ///
	order(last_agen_hear lXagen_nwords_last_hr lXagen_nwitnessagency_last_hr agen_hear_all) ///
	nomtitles ///
	mgroups("Agency-level" "Program-level", ///
				pattern(1 0 1 0) ///
				span prefix(\multicolumn{@span}{c}{) suffix(})) ///
	prefoot("\hline") ///
	postfoot("\bottomrule \multicolumn{5}{l}{\footnotesize Standard errors in parentheses; clustered on agency-year for program-level analysis.}\\ \multicolumn{4}{l}{\footnotesize \sym{**} \(p<0.05\), \sym{***} \(p<0.01\)}\\ \end{tabular} } \\ \label{tab:moderatorsdyn} \end{table}") replace
	
	
	